package ${packInfo.Controller};

import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import cn.superchart.common.base.BaseController;
import org.springframework.validation.annotation.Validated;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.superchart.common.base.BaseResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
import ${packInfo.Parent}.param.*;
import ${packInfo.Service}.${table.serviceName};
/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
@Validated
<#else>
@Controller
@Validated
</#if>
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if> extends BaseController<${table.serviceName}>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} extends BaseController<${table.serviceName}>{
</#if>




      @PostMapping("/sc/${lowEntity}/page")
      public BaseResult<Page<${entity}DetailParam>> page(@RequestBody @Valid ${entity}PageParam ${lowEntity}PageParam) {
          Page<${entity}DetailParam> page = service.page(${lowEntity}PageParam);
          return BaseResult.result(page);
      }


      @PostMapping("/sc/${lowEntity}/add")
      public BaseResult<String> add(@RequestBody @Valid ${entity}AddParam ${lowEntity}AddParam) {
          service.add(${lowEntity}AddParam);
          return BaseResult.ok();
      }

      @PostMapping("/sc/${lowEntity}/edit")
      public BaseResult<String> edit(@RequestBody @Valid ${entity}EditParam ${lowEntity}EditParam) {
          service.edit(${lowEntity}EditParam);
          return BaseResult.ok();
      }

      @GetMapping("/sc/${lowEntity}/detail")
      public BaseResult<${entity}DetailParam> detail( @Valid ${entity}IdParam ${lowEntity}IdParam) {
          return BaseResult.result(service.detail(${lowEntity}IdParam.getId()));
      }


      @DeleteMapping("/sc/${lowEntity}/delete")
      public BaseResult<Boolean> delete(@Valid ${entity}IdParam ${lowEntity}IdParam) {
         Boolean res = service.delete(${lowEntity}IdParam.getId());
         return BaseResult.result(res);
      }






}
</#if>
